package com.woniu.new_orange.service_model_gao.controller;

import com.woniu.new_orange.entity.VisitRecord;
import com.woniu.new_orange.service_model_gao.service.VisitRecordService;
import com.woniu.new_orange.service_model_gao.vo.VisitRecordVo;
import com.woniu.new_orange.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Program: new_orange->VisitRecordController
 * @Description: 用户访问表
 * @Author: gao chaozhe
 * @Date: 2023-02-02 17:04
 * @Version： 1.0
 **/
@RestController
@RequestMapping("/visit")
@Api(value = "用户访问记录",tags="页面咨询")
public class VisitRecordController {
    @Autowired
    private VisitRecordService visitRecordService;

    @GetMapping("")
    @ApiOperation(value = "通过当前客服员工id获取用户记录表全部数据",notes = "通过当前客服员工id获取用户记录表全部数据")
    public Result queryAll(){
        List<VisitRecordVo> visitRecords = visitRecordService.selectAll();
        return Result.ok().data("visitRecordList",visitRecords);
    }

    @PostMapping("")
    @ApiOperation(value = "像用户访问记录表中添加数据",notes = "从前端页面获取数据后存入数据库中")
    public Result add(@RequestBody VisitRecord record){
        int i = visitRecordService.insertSelective(record);
        return Result.ok();
    }
}
